# Maintainer: Dimitrij Mijoski <dmjpp@hotmail.com>

_realname=nuspell
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=5.1.3
pkgrel=1
pkgdesc="Fast and safe spellchecking C++ library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://nuspell.github.io/"
license=('spdx:LGPL-3.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-catch"
             "${MINGW_PACKAGE_PREFIX}-cc")
depends=("${MINGW_PACKAGE_PREFIX}-icu")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/nuspell/nuspell/archive/v${pkgver}.tar.gz")
sha256sums=('2b1c96bdc5a32a17fc8fc24a0c205fa52b0a2920dd6139b0a7d7744cdef48c22')
sha512sums=('72c868f734848be79c7cfb0502298626307213e4f3f422f8e9ee7dac24cb3d79ea55d04ef0443e7107bb11eb545c79a15a8aea8cb056dc2805c23bd5e3292562')

build() {
  mkdir -p ${srcdir}/build-${MSYSTEM} && cd ${srcdir}/build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -GNinja \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    ../"${_realname}-${pkgver}"

  ${MINGW_PREFIX}/bin/cmake.exe --build ./
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/ctest.exe ./ || true
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake.exe --install ./

  # Licenses
  cd "${srcdir}/${_realname}-${pkgver}"
  install -Dm644 COPYING      "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
  install -Dm644 COPYING.LESSER "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.LESSER"
}
